// import COSSDK from 'cos-wx-sdk-v5'
import TIM from './sdk/tim-wx.js'
import genTestUserSig from './sdk/GenerateTestUserSig.js'
import Vue from 'vue'

const tim = TIM.create({
  SDKAppID: genTestUserSig('').SDKAppID
})
tim.setLogLevel(0)
// tim.registerPlugin({'cos-wx-sdk':COSSDK})

Vue.prototype.$tim = tim
Vue.prototype.$TIM = TIM
Vue.prototype.$TIM_INIT = function() {
	uni.$app.$TIM_INIT.prototype = {...uni.$app.prototype, ...uni.$app.$TIM_INIT.prototype}
	let userInfo = this.$store.state.userInfo
	
	this.$http.url_Request('/applet/yapp/tensig', {
		user_id: userInfo.id
	}, 'POST').then(res=>{
		console.log(res)
		tim.login({
			userID: userInfo.id,
			userSig: res.data
		})
	})
}

export default {
    init() {
        console.log("*** tim installed ***")
    }
}
